Skip to content

Fix image decoding errors in picture_viewer for mismatched file extensions#25

Merged
joone merged 7 commits intomainfrom
copilot/fix-decoding-error-picture-viewer
Feb 7, 2026
Merged

Fix image decoding errors in picture_viewer for mismatched file extensions#25
joone merged 7 commits intomainfrom
copilot/fix-decoding-error-picture-viewer

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 7, 2026

The picture_viewer example fails to decode images downloaded from the Disney API with Decoding(DecodingError { format: Exact(Jpeg), underlying: Some(Error parsing image. Illegal start bytes:5249) }). The API returns WebP images (RIFF header 0x5249), but the code saves them with .jpg extensions. The image decoder relies on file extension and fails on format mismatch.

Changes

  • src/layer.rs: Replace image::open() with ImageReader::open().with_guessed_format() to detect format from file content rather than extension
// Before
image::open(&Path::new(&self.image_path))

// After  
image::ImageReader::open(&Path::new(&self.image_path))
  .and_then(|reader| reader.with_guessed_format())
  .map_err(image::ImageError::IoError)
  .and_then(|reader| reader.decode())

This enables format auto-detection for any image loading scenario where file extensions may not match actual content.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • api.disneyapi.dev
    • Triggering command: /usr/bin/curl curl -s REDACTED /home/REDACTED/work/rust-animation/rust-animation/target/debug/build/aws-lc-sys-77/home/REDACTED/work/rust-animation/rust-animation/target/debug/examples/picture_viewer-a5d8ac28b8ee59b4.1958j2bm6jwkptbsq0nq8slxj.0iozfs4.rcgu.o /home/REDACTED/work/rust-animation/rust-animation/target/debug/build/aws-lc-sys-77/home/REDACTED/work/rust-animation/rust-animation/target/debug/examples/picture_viewer-a5d8ac28b8ee59b4.196l9orhjpu9f270a1ouhgkxv.0iozfs4.rcgu.o 1b3cfb4b0e8bfb/out/libaws_lc_0_37_0_crypto.a 1b3cfb4b0e8bfb/out/ebcd52e9457b6221-v3_genn.o 1b3cfb4b0e8bfb/out/ebcd52e9457b6221-v3_ia5.o 1b3cfb4b0e8bfb/out/ebcd52e9457b6221-v3_info.o 1b3cfb4b0e8bfb/out/ebcd52e9457b6221-v3_int.o 1b3cfb4b0e8bfb/out/ebcd52e9457b6221-v3_lib.o 1b3cfb4b0e8bfb/out/ebcd52e9457b6221-v3_ncons.o 1b3cfb4b0e8bfb/out/ebcd52e9457b6221-v3_ocsp.o 1b3cfb4b0e8bfb/out/ebcd52e9457b6221-v3_pcons.o 1b3cfb4b0e8bfb/out/ebcd52e9457b6221-v3_pmaps.o 1b3cfb4b0e8bfb/out/ebcd52e9457b6221-v3_prn.o 1b3cfb4b0e8bfb/out/ebcd52e9457b6221-v3_purp.o 1b3cfb4b0e8bfb/out/ebcd52e9457b6221-v3_skey.o 1b3cfb4b0e8bfb/out/ebcd52e9457b6221-v3_utl.o 1b3cfb4b0e8bfb/out/ebcd52e9457b6221-x509.o (dns block)
    • Triggering command: /usr/bin/curl curl -s REDACTED embed-bitcode=no -C 1b3cfb4b0e8bfb/out/libaws_lc_0_37_0_crypto.a 1b3cfb4b0e8bfb/out/8f1694c3e3041570-bignum_montinv_p256.o 1b3cfb4b0e8bfb/out/8f1694c3e3041570-p256_montjscalarmul.o 1b3cfb4b0e8bfb/out/8f1694c3e3041570-p256_montjscalarmul_alt.o 1b3cfb4b0e8bfb/out/4433246e317b5e42-bignum_add_p384.o 1b3cfb4b0e8bfb/out/4433246e317b5e42-bignum_deamont_p384.o 1b3cfb4b0e8bfb/out/4433246e317b5e42-bignum_deamont_p384_alt.o 1b3cfb4b0e8bfb/out/4433246e317b5e42-bignum_littleendian_6.o 1b3cfb4b0e8bfb/out/4433246e317b5e42-bignum_montinv_p384.o 1b3cfb4b0e8bfb/out/4433246e317b5e42-bignum_montmul_p384.o 1b3cfb4b0e8bfb/out/4433246e317b5e42-bignum_montmul_p384_alt.o 1b3cfb4b0e8bfb/out/4433246e317b5e42-bignum_montsqr_p384.o 1b3cfb4b0e8bfb/out/4433246e317b5e42-bignum_montsqr_p384_alt.o 1b3cfb4b0e8bfb/out/4433246e317b5e42-bignum_neg_p384.o 1b3cfb4b0e8bfb/out/4433246e317b5e42-bignum_nonzero_6.o (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 5 commits February 7, 2026 18:18
Co-authored-by: joone <1979160+joone@users.noreply.github.com>
…art guide

Co-authored-by: joone <1979160+joone@users.noreply.github.com>
[WIP] Implement fully automated GitHub release process for Rust repo
Copilot AI and others added 2 commits February 7, 2026 18:35
Co-authored-by: joone <1979160+joone@users.noreply.github.com>
Co-authored-by: joone <1979160+joone@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix decoding error in picture_viewer example Fix image decoding errors in picture_viewer for mismatched file extensions Feb 7, 2026
Copilot AI requested a review from joone February 7, 2026 18:41
@joone joone marked this pull request as ready for review February 7, 2026 18:43
@joone joone merged commit 2561b2d into main Feb 7, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants